<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="150px" style="margin-left: 50px;margin-top: 30px;width: 700px">
      <el-form-item label="维修设备名称" prop="name">
        <el-input v-model="form.name" placeholder="维修设备名称"/>
      </el-form-item>
      <el-form-item label="维修设备类别" prop="type">
        <el-input v-model="form.type" placeholder="维修设备类别"/>
      </el-form-item>
      <el-form-item label="维修配件品牌" prop="brand">
        <el-input v-model="form.brand" placeholder="维修配件品牌"/>
      </el-form-item>

      <el-form-item label="请选择维修日期" prop="repairDate">
        <el-date-picker clearable
            v-model="form.repairDate"
            type="date"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择维修日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="维修数量" prop="repairCount">
        <el-input-number v-model="form.repairCount" size="small" :min="0" :max="30" label="请输入维修数量"></el-input-number>
        <span style="margin-left: 5px">个</span>
      </el-form-item>
      <el-form-item label="预计维修费用" prop="repairWages">
        <el-input-number v-model="form.repairWages" size="small" :min="0" :max="1000" label="请输入预计维修费用"></el-input-number>
        <span style="margin-left: 5px">元</span>
      </el-form-item>

      <el-form-item label="申请理由" prop="reason">
        <el-input
          type="textarea"
          :autosize="{ minRows: 2, maxRows: 5}"
          placeholder="请输入申请理由"
          v-model="form.reason">
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">申请</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>

  </div>
</template>

<script>
import { addRepair } from "@/api/system/repair";

export default {
  name: "RepairApp",
  data() {
    return {
      form: {
        cost:0
      }
    }
  },
  created() {
    // this.getList();
  },
  methods: {
    onSubmit() {
      addRepair(this.form).then(response => {
        this.$modal.msgSuccess("新增成功");
        this.reset();
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        startDate: null,
        endDate: null,
        target: null,
        objective: null,
        cost: null
      };
      this.resetForm("form");
    },

  }
};
</script>
